home *** CD-ROM | disk | FTP | other *** search
/ Trusted Irix /B 4.0.4 / Trusted-Irix B-4.0.1.iso / dist / eoe1.idb / usr / include / sys / signal.h.z / signal.h
C/C++ Source or Header  |  1992-04-03  |  13KB  |  410 lines

  1. /* Copyright (C) 1989,1990 Silicon Graphics, Inc. All rights reserved.  */
  2.  
  3. #ifndef __SYS_SIGNAL_H__
  4. #define __SYS_SIGNAL_H__
  5.  
  6. #ifdef __cplusplus
  7. extern "C" {
  8. #endif
  9.  
  10. /*    Copyright (c) 1984 AT&T    */
  11. /*      All Rights Reserved      */
  12.  
  13. /*    THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T    */
  14. /*    The copyright notice above does not evidence any       */
  15. /*    actual or intended publication of such source code.    */
  16.  
  17. /* #ident    "$Revision: 3.45 $" */
  18.  
  19. /* ANSI C Notes:
  20.  *
  21.  * - THE IDENTIFIERS APPEARING OUTSIDE OF #ifdef __EXTENSIONS__ IN THIS
  22.  *   standard header ARE SPECIFIED BY ANSI!  CONFORMANCE WILL BE ALTERED
  23.  *   IF ANY NEW IDENTIFIERS ARE ADDED TO THIS AREA UNLESS THEY ARE IN ANSI's
  24.  *   RESERVED NAMESPACE. (i.e., unless they are prefixed by __[a-z] or
  25.  *   _[A-Z].  For external objects, identifiers with the prefix _[a-z] 
  26.  *   are also reserved.)
  27.  *
  28.  * - Section 4.7 indicates that identifiers beginning with SIG or SIG_
  29.  *   followed by an upper-case letter are added to the reserved namespace
  30.  *   when including <signal.h>.
  31.  */
  32.  
  33.  
  34. #define    SIGHUP    1    /* hangup */
  35. #define    SIGINT    2    /* interrupt (rubout) */
  36. #define    SIGQUIT    3    /* quit (ASCII FS) */
  37. #define    SIGILL    4    /* illegal instruction (not reset when caught)*/
  38. #define    SIGTRAP    5    /* trace trap (not reset when caught) */
  39. #define    SIGIOT    6    /* IOT instruction */
  40. #define SIGABRT 6    /* used by abort, replace SIGIOT in the  future */
  41. #define    SIGEMT    7    /* EMT instruction */
  42. #define    SIGFPE    8    /* floating point exception */
  43. #define    SIGKILL    9    /* kill (cannot be caught or ignored) */
  44. #define    SIGBUS    10    /* bus error */
  45. #define    SIGSEGV    11    /* segmentation violation */
  46. #define    SIGSYS    12    /* bad argument to system call */
  47. #define    SIGPIPE    13    /* write on a pipe with no one to read it */
  48. #define    SIGALRM    14    /* alarm clock */
  49. #define    SIGTERM    15    /* software termination signal from kill */
  50. #define    SIGUSR1    16    /* user defined signal 1 */
  51. #define    SIGUSR2    17    /* user defined signal 2 */
  52. #define    SIGCLD    18    /* death of a child */
  53. #define SIGCHLD SIGCLD    /* 4.3BSD's name */
  54. #define    SIGPWR    19    /* power-fail restart */
  55.  
  56. /* 4.3BSD job control */
  57. #define    SIGSTOP    20    /* sendable stop signal not from tty */
  58. #define    SIGTSTP    21    /* stop signal from tty */
  59.  
  60. #define SIGPOLL 22    /* pollable event occurred */
  61.  
  62. /* 4.3BSD signals */
  63. #define    SIGIO    23    /* input/output possible signal */
  64. #define    SIGURG    24    /* urgent condition on IO channel */
  65. #define    SIGWINCH 25    /* window size changes */
  66. #define SIGVTALRM 26    /* virtual time alarm */
  67. #define SIGPROF    27    /* profiling alarm */
  68.  
  69. /* 4.3BSD job control */
  70. #define    SIGCONT    28    /* continue a stopped process */
  71. #define    SIGTTIN    29    /* to readers pgrp upon background tty read */
  72. #define    SIGTTOU    30    /* like TTIN for output if (tp->t_local<OSTOP) */
  73.  
  74. /* 4.3BSD CPU- and Filesize-limit signals */
  75. #define SIGXCPU    31    /* Cpu time limit exceeded */
  76. #define SIGXFSZ    32    /* Filesize limit exceeded */
  77.  
  78.  
  79. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  80.  
  81. #if defined(__EXTENSIONS__) || defined(_POSIX_SOURCE)
  82. /*
  83.  * Definitions for POSIX signal system calls
  84.  */
  85.  
  86. typedef unsigned long sigset_t;
  87.  
  88. typedef struct sigaction {
  89. #if defined(_LANGUAGE_C_PLUS_PLUS) 
  90. #if defined(_BSD_COMPAT) || defined(_BSD_SIGNALS)
  91.   int (*sa_handler)(int,...);    /* SIG_DFL, SIG_IGN, BSD_SIG_IGN or *fn */
  92. #else
  93.   void (*sa_handler)(int,...);    /* SIG_DFL, SIG_IGN, BSD_SIG_IGN or *fn */
  94. #endif /* BSD */
  95. #else /* not C++ */
  96. # if defined(_BSD_COMPAT) || defined(_BSD_SIGNALS)
  97.   int (*sa_handler)();    /* SIG_DFL, SIG_IGN, BSD_SIG_IGN or *fn */
  98. # else
  99.   void (*sa_handler)();    /* SIG_DFL, SIG_IGN, BSD_SIG_IGN or *fn */
  100. # endif /* BSD */
  101. #endif /* C++ */
  102.   sigset_t sa_mask;        /* additional set of sigs to be        */
  103.                 /* blocked during handler execution    */
  104.   int sa_flags;            /* see below for values            */
  105. } sigaction_t;
  106.  
  107. /* sa_flags values */
  108. #define SA_NOCLDSTOP    0x1    /* if set in parent, don't send SIGCLD    */
  109.                 /* to parent when child stop        */
  110. #define _SA_BSDCALL    0x2    /* if set, a clr NOCLDSTOP doesn't set    */
  111.                 /* SJCTRL bit in proc struct.        */
  112. #define SA_ONSTACK    0x4    /* handle this signal on sigstack */
  113.  
  114. /*
  115.  * Structure used in sigstack call.
  116.  */
  117. struct    sigstack {
  118.     char    *ss_sp;            /* signal stack pointer */
  119.     int    ss_onstack;        /* current status */
  120. };
  121.  
  122. /*
  123.  * Definitions for the "how" parameter to sigprocmask():
  124.  *
  125.  * The parameter specifies whether the bits in the incoming mask are to be
  126.  * added to the presently-active set for the process, removed from the set,
  127.  * or replace the active set.
  128.  */
  129. #define SIG_NOP        0    /* Not using 0 will catch some user errors. */
  130. #define SIG_BLOCK    1
  131. #define SIG_UNBLOCK    2
  132. #define SIG_SETMASK    3
  133.  
  134. #endif /* __EXTENSIONS__ || _POSIX_SOURCE */
  135.  
  136.  
  137. /* The following typdefs SIG_PF as a function returning a ptr to:
  138.  *    a) void with 1 or more parameters for ANSI,
  139.  *    b) int with old style (no parameters specified) declaration for BSD,
  140.  *    c) void with old style (no params specified) dec. for regular c.
  141.  */
  142.  
  143. #if defined(_LANGUAGE_C_PLUS_PLUS)
  144. # if  (defined(_BSD_COMPAT) || defined(_BSD_SIGNALS))
  145. typedef int    (*SIG_PF) (int, ...);
  146. # else
  147. typedef void    (*SIG_PF) (int, ...);
  148. # endif /* BSD */
  149. #else    /* not C++ */
  150. # if defined(_BSD_COMPAT) || defined(_BSD_SIGNALS)
  151. typedef int    (*SIG_PF) ();
  152. # else
  153. typedef void    (*SIG_PF) ();
  154. #endif /* BSD */
  155.  
  156. # endif    /* C++ */
  157. /* next 4 are for C or C++ */
  158. #define SIG_ERR        ((SIG_PF)-1)
  159. #define    SIG_IGN        ((SIG_PF)1)
  160. #define SIG_HOLD    ((SIG_PF)2)
  161. #define    SIG_DFL        ((SIG_PF)0)
  162. #else    /* then for assembly or FORTRAN inclusion */
  163. #define SIG_ERR        (-1)
  164. #define    SIG_IGN        (1)
  165. #define SIG_HOLD    (2)
  166. #define    SIG_DFL        (0)
  167. #endif    /* C || C++ */
  168.  
  169. #if defined (_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  170. typedef int    sig_atomic_t; /* for ANSI && c++ et all */
  171. #endif
  172.  
  173. #if defined(__EXTENSIONS__) && !defined(_POSIX_SOURCE)
  174.  
  175. /*
  176.  * BSD and POSIX treat SIG_IGN of SIGCHLD like SysV's SIG_DFL, so we flag it
  177.  * differently FOR INTERNAL USE ONLY.  This allows the kernel to treat it
  178.  * like SysV's SIG_DFL, but identify it as BSD's SIG_IGN, enabling sigvec
  179.  * and sigaction to return SIG_IGN in signal-handling queries.
  180.  */
  181. #ifdef _KERNEL
  182. #define    BSD_SIG_IGN    (void (*)())(3)
  183. #endif /* _KERNEL */
  184.  
  185. /* For some reason, NSIG is 1 more than the # of signals supported in system */
  186. #define    NSIG        33    /* valid signal numbers are from 1 to NSIG-1 */
  187. #define MAXSIG        (NSIG-1)    /* actual # of signals == 32 for now */
  188. #define    NUMSIGS        (NSIG-1)    /* for POSIX array sizes, true # of sigs */
  189.  
  190. #if _LINT
  191. #undef SIG_ERR
  192. #define SIG_ERR (void(*)())0
  193. #undef SIG_IGN
  194. #define    SIG_IGN    (void (*)())0
  195. #undef SIG_HOLD
  196. #define    SIG_HOLD (void (*)())0
  197. #undef BSD_SIG_IGN
  198. #define    BSD_SIG_IGN (void (*)())0
  199. #endif /* _LINT */
  200.  
  201. /* The following definitions are only used by kernel */
  202. #ifdef _KERNEL
  203. #define SIGNO_MASK    0xff
  204. #define SIGDEFER    0x100
  205. #define SIGHOLD        0x200
  206. #define SIGRELSE    0x400
  207. #define SIGIGNORE    0x800
  208. #define SIGPAUSE    0x1000
  209.  
  210. /* Possible save/restore interfaces encountered when issuing a signal */
  211. #define SIG_TRAP    0
  212. #define SIG_SYSCALL    1
  213. #endif /* _KERNEL */
  214.  
  215. /* Convert signal number to bit mask representation */
  216. #define sigmask(sig)    (1L << ((sig)-1))
  217.  
  218. #define    BRK_USERBP    0    /* user bp (used by debuggers) */
  219. #define    BRK_KERNELBP    1    /* kernel bp (used by prom) */
  220. #define    BRK_ABORT    2    /* abort(3) uses to cause SIGIOT */
  221. #define    BRK_BD_TAKEN    3    /* for taken bd emulation */
  222. #define    BRK_BD_NOTTAKEN    4    /* for not taken bd emulation */
  223. #define    BRK_SSTEPBP    5    /* user bp (used by debuggers) */
  224. #define    BRK_OVERFLOW    6    /* overflow check */
  225. #define    BRK_DIVZERO    7    /* divide by zero check */
  226. #define    BRK_RANGE    8    /* range error check */
  227. #define    BRK_MULOVF    1023    /* multiply overflow detected */
  228.  
  229. #if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS)
  230.  
  231. /* sigaltstack info */
  232. #define MINSIGSTKSZ    512
  233. #define SIGSTKSZ    8192
  234.  
  235. struct sigaltstack {
  236.     char *ss_sp;
  237.     int  ss_size;
  238.     int  ss_flags;
  239. };
  240. typedef struct sigaltstack stack_t;
  241.  
  242. /* defines for ss_flags */
  243. #define SS_ONSTACK    0x00000001
  244. #define SS_DISABLE    0x00000002
  245.  
  246.  
  247.  
  248. /*
  249.  * Information pushed on stack when a signal is delivered. This is used by
  250.  * the kernel to restore state following execution of the signal handler.
  251.  * It is also made available to the handler to allow it to properly restore
  252.  * state if a non-standard exit is performed.
  253.  *
  254.  * sc_regmask is examined by the kernel when doing sigcleanup()'s
  255.  * and indicates which registers to restore from sc_regs
  256.  * bit 0 == 1 indicates that all coprocessor state should be restored
  257.  *    for each coprocessor that has been used
  258.  * bits 1 - 31 == 1 indicate registers 1 to 31 should be restored by
  259.  *    sigcleanup from sc_regs.
  260.  *
  261.  * NOTE: the libc routines setjmp/longjmp must agree with this.
  262.  */
  263. struct sigcontext {
  264.     int    sc_regmask;        /* regs to restore in sigcleanup */
  265.     int    sc_mask;        /* signal mask to restore */
  266.     int    sc_pc;            /* pc at time of signal */
  267.     /*
  268.      * General purpose registers
  269.      */
  270.     int    sc_regs[32];    /* processor regs 0 to 31 */
  271.     /*
  272.      * Floating point coprocessor state
  273.      */
  274.     int    sc_ownedfp;    /* fp has been used */
  275.     int    sc_fpregs[32];    /* fp regs 0 to 31 */
  276.     int    sc_fpc_csr;    /* floating point control and status reg */
  277.     int    sc_fpc_eir;    /* floating point exception instruction reg */
  278.     int    sc_mdhi;    /* Multiplier hi and low regs */
  279.     int    sc_mdlo;
  280.     /*
  281.      * System coprocessor registers at time of signal
  282.      */
  283.     int    sc_cause;    /* cp0 cause register */
  284.     int    sc_badvaddr;    /* cp0 bad virtual address */
  285.     int    sc_badpaddr;    /* cpu bd bad physical address */
  286.     int    is_sigset;
  287.     int    sc_triggersave;    /* state of graphics trigger (SGI IP5 only) */
  288.     int    sc_ssflags;    /* signal stack state to restore */
  289. };
  290.  
  291. /*
  292.  * The next section contains declarations and typedefs for the BSD signal
  293.  * library routines built on top of the POSIX system calls.  Two of them,
  294.  * signal() and sigpause(), share names with their SysV counterparts, yet
  295.  * have different semantics.  By default, the SysV versions are used.
  296.  * In order to use the BSD versions, you may either:
  297.  *  1) explicitly call BSDsignal() and BSDsigpause() in the program, or
  298.  *  2) set one of the _BSD_SIGNALS or _BSD_COMPAT cpp constants before 
  299.  *     including the signal header file. There are 2 methods:
  300.  *     a) modify the source file, e.g.,
  301.  *        #ifdef sgi
  302.  *          #define _BSD_SIGNALS
  303.  *          #endif
  304.  *          #include <signal.h>
  305.  *     b) use the cc(1) option -D_BSD_SIGNALS or -D_BSD_COMPAT.
  306.  *        e.g., cc -D_BSD_SIGNALS foo.c -o foo
  307.  * Note that _BSD_COMPAT affects other header files that deal with BSD
  308.  * compatibility.
  309.  */
  310.  
  311. #ifndef _KERNEL
  312.  
  313. #include <sys/types.h>
  314.  
  315. #if defined(_BSD_COMPAT) || defined(_BSD_SIGNALS)
  316.  
  317. struct sigvec {
  318. #if defined(_LANGUAGE_C_PLUS_PLUS) 
  319.   int (*sv_handler)(int,...);    /* SIG_DFL, SIG_IGN, BSD_SIG_IGN or *fn */
  320. #else
  321.   int (*sv_handler)();    /* *handler, SIG_DFL, SIG_IGN, or BSD_SIG_IGN */
  322. #endif /* C */
  323.   int sv_mask;        /* mask to use during handler execution        */
  324.   int sv_flags;        /* see signal options below */
  325. };
  326.  
  327. #define SV_ONSTACK    0x0001
  328. #define SV_INTERRUPT    0x0002        /* not supported */
  329. #define sv_onstack    sv_flags    /* compatibility with BSD */
  330.  
  331. #define NUMBSDSIGS    (NSIG-1)  /* Currently==MAXSIG, but won't ever expand */
  332.  
  333. #define signal        BSDsignal
  334. #define sigpause    BSDsigpause
  335.  
  336. #ifdef __cplusplus
  337. #ifndef __SYS_SIGNAL_H_SIGNAL__
  338. #define __SYS_SIGNAL_H_SIGNAL__
  339. extern int    (*signal(int,int (*)(int, ...)))(int, ...);
  340. #endif /* __SYS_SIGNAL_H_SIGNAL__ */
  341. #else
  342. #ifndef __SYS_SIGNAL_H_SIGNAL__
  343. #define __SYS_SIGNAL_H_SIGNAL__
  344. extern int    (*signal(int,int (*)()))();
  345. #endif /* __SYS_SIGNAL_H_SIGNAL__ */
  346. #endif
  347.  
  348. extern int    sigpause(int);
  349. extern int    sigvec(int,struct sigvec *, struct sigvec *);
  350. extern int    sigstack(struct sigstack *, struct sigstack *);
  351. extern int    sigblock(int);
  352. extern int    sigsetmask(int);
  353. extern int    killpg(int, int);
  354. extern int    kill(int, int);
  355.  
  356. #else
  357.  
  358. #ifdef __cplusplus
  359. #ifndef __SYS_SIGNAL_H_SIGNAL__
  360. #define __SYS_SIGNAL_H_SIGNAL__
  361. extern void    (*signal(int,void (*)(int, ...)))(int, ...);
  362. #endif /* __SYS_SIGNAL_H_SIGNAL__ */
  363. #else
  364. #ifndef __SYS_SIGNAL_H_SIGNAL__
  365. #define __SYS_SIGNAL_H_SIGNAL__
  366. extern void    (*signal(int,void (*)()))();
  367. #endif /* __SYS_SIGNAL_H_SIGNAL__ */
  368. #endif
  369.  
  370. extern int    sigpause(int);
  371. extern int    sighold(int);
  372. extern int    sigrelse(int);
  373. extern int    kill(pid_t, int);
  374.  
  375. #endif /* BSD */
  376.  
  377. #ifndef __cplusplus
  378. #ifdef __STDC__
  379. /* declare signal for ANSI.  NOTE! no arg information for the handler function
  380.    is specified!  DON'T MESS WITH THIS!
  381. */
  382. #ifndef __SYS_SIGNAL_H_SIGNAL__
  383. #define __SYS_SIGNAL_H_SIGNAL__
  384. extern void    (*signal(int,void (*)()))();
  385. #endif /* __SYS_SIGNAL_H_SIGNAL__ */
  386. #endif /* __STDC__ */
  387. #endif /* __cplusplus */
  388.  
  389. #endif /* !_KERNEL */
  390.  
  391. #endif /* _LANGUAGE_C || _LANGUAGE_C_PLUS_PLUS */
  392. #endif /* __EXTENSIONS__ && !_POSIX_SOURCE */
  393.  
  394. #if defined(_LANGUAGE_C) && !defined(_KERNEL)
  395. /* declare signal for C.  NOTE! no arg information for the handler function
  396.    is specified!  DON'T MESS WITH THIS!
  397. */
  398. #ifndef __SYS_SIGNAL_H_SIGNAL__
  399. #define __SYS_SIGNAL_H_SIGNAL__
  400. extern void    (*signal(int,void (*)()))();
  401. #endif /* __SYS_SIGNAL_H_SIGNAL__ */
  402. #endif /* _LANGUAGE_C && !_KERNEL */
  403.  
  404. #ifdef __cplusplus
  405. }
  406. #endif
  407.  
  408. #endif /* !__SYS_SIGNAL_H__ */
  409.  
  410.